import { prop, Ref } from "@typegoose/typegoose";
import { Url } from "url";
import { ApiModelProperty } from "@nestjs/swagger";
import { Order } from "./order.model";
import { IsNotEmpty, IsUrl, IsArray } from "class-validator";

export class Comment {
  @ApiModelProperty({ description: '订单', example: 'Order._id', type: String })
  @prop({ ref: Order })
  @IsNotEmpty({ message: '请输入订单信息' })
  order!: Ref<Order>

  @ApiModelProperty({ description: '评论信息', example: '很好用的产品' })
  @prop()
  @IsNotEmpty({ message: '不能输入空白评论' })
  message!: String

  @ApiModelProperty({ description: '附带图片', example: ['https://shubuzuo.top/img/logo.jpg', 'https://shubuzuo.top/img/logo.jpg'], type: [String], required: false })
  @prop()
  @IsArray()
  images?: Array<Url>
}